from time import sleep
from selenium import webdriver
from selenium.webdriver import ActionChains
from selenium.webdriver.chrome.service import Service
from selenium.webdriver.common.by import By

#实例化对象：

service = Service(executable_path="E:\python\python38\chromedriver.exe")
driver = webdriver.Chrome(service=service)
driver.get("http://121.43.169.97:8848/pageA.html")
action = ActionChains(driver)
driver.maximize_window()
sleep(5)
# #打开注册页面A，在用户名文本框上点击鼠标右键
# username=driver.find_element(By.CSS_SELECTOR,"#userA")
# #调用右击方法
# cc=action.context_click(username)
# #执行
# cc.perform()
# #上面三行合并为下面一行
# action.context_click(driver.find_element(By.CSS_SELECTOR,"#userA")).perform()
#输入用户名admin'
username2= driver.find_element(By.CSS_SELECTOR,"#userA").send_keys("admin")
#暂停3秒
sleep(3)
#双击鼠标左键，选择admin
action.double_click(username2).perform()
#鼠标移动到注册按钮上面，预期按钮变色
button=driver.find_element(By.XPATH,"//p[5]/button")
action.move_to_element(button).perform()